# $Id$
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Matt Monaco <cx monaco matt>

pkgname=lmdb
pkgver=0.9.21
pkgrel=1
pkgdesc="Symas Lightning Memory-Mapped Database"
arch=('i686' 'x86_64')
url="http://symas.com/mdb"
license=('custom:OpenLDAP')
depends=('glibc')
options=('!emptydirs')
source=("$pkgname-$pkgver.tar.gz::https://github.com/LMDB/lmdb/archive/LMDB_$pkgver.tar.gz" lmdb.pc)
sha512sums=('e0f998507da654ccac02aa199367e8363c37f47e06ee0984085aae60fb086e49087824915bf8896f90187f1cc96e5c9caf5e5f72fa3911415151ca1e56f0309f'
            '0349d4b08a1f93fe338d8f8e3e5a83e24211a46f999fe529bc1ac49c8c4975559d95a548c203d9427e3f82d62e934ba3cd1be6f734f9b9405b2a26477be4ed33')

prepare() {
  sed -e "s|@PKGVER@|$pkgver|" -i lmdb.pc
}

build() {
  cd "$srcdir"/lmdb-LMDB_$pkgver/libraries/liblmdb
  make prefix=/usr
}

check() {
  cd "$srcdir"/lmdb-LMDB_$pkgver/libraries/liblmdb
  make test
}

package() {
  cd "$srcdir"/lmdb-LMDB_$pkgver/libraries/liblmdb
  install -dm755 "$pkgdir"/usr/{bin,lib,include,man/man1,share}
  make DESTDIR="$pkgdir" prefix=/usr install

  mv "$pkgdir"/usr/man "$pkgdir"/usr/share/man

  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
  install -Dm644 "$srcdir"/lmdb.pc "$pkgdir"/usr/lib/pkgconfig/lmdb.pc
}
